import ajax from './ajax'

const BASE_URL = '/api'

export const reqLeaveWorld = () => ajax(`${BASE_URL}/leaveWorld/`)

export const reqAddLeaveWorld = ({nickname, text}) => ajax(`${BASE_URL}/leaveWorld/add`, {nickname, text}, 'POST')

export const reqRemoveLeaveWorld = id => ajax(`${BASE_URL}/leaveWorld/delete/${id}`, {}, 'DELETE')

export const reqAddReply = reply => ajax(`${BASE_URL}/leaveWorld//addComment/${reply.id}`, {comment: reply.comments}, 'POST')

export const reqRemoveReply = reply => ajax(`${BASE_URL}/leaveWorld/removeComment/${reply.id}/${reply.comment}`, {}, 'DELETE')

export const reqBlogs = () => ajax(`${BASE_URL}/blog/`)

export const reqSearchBlogs = keyword => ajax(`${BASE_URL}/blog/search/`, keyword, 'POST')

export const reqMusic = () => ajax(`${BASE_URL}/music/`)

export const reqMusicLike = likes => ajax(`${BASE_URL}/music/love/${likes.id}`, {like: likes.like})

export const reqAddBlog = blog => ajax(`${BASE_URL}/blog/add`, blog, 'POST')

export const reqBlogDetails = blogId => ajax(`${BASE_URL}/blog/${blogId}`)

export const reqRemoveBlog = id => ajax(`${BASE_URL}/blog/delete/${id}`, {}, 'DELETE')

export const reqCases = () => ajax(`${BASE_URL}/case/`)

export const reqRemoveCase = id => ajax(`${BASE_URL}/case/delete/${id}`, {}, 'DELETE')

export const reqUser = user => ajax(`${BASE_URL}/user/`, user, 'POST')

export const reqIntroduce = () => ajax(`${BASE_URL}/introduce/`)

export const reqSingleIntroduce = id => ajax(`${BASE_URL}/introduce/${id}`)

export const reqAddCases = cases => ajax(`${BASE_URL}/case/add`, cases, 'POST')

export const reqFabulous = blog => ajax(`${BASE_URL}/blog/fabulous/${blog.id}`, blog, 'POST')

export const reqStep = blog => ajax(`${BASE_URL}/blog/step/${blog.id}`, blog, 'POST')
